home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / PowerPlant / Multi-Panel Dialogs 1.1 / MPD Sources / CMPDGrayCouncilTabs.cp < prev    next >
Encoding:
Text File  |  1996-11-14  |  7.5 KB  |  175 lines  |  [TEXT/R*ch]

  1. // ===========================================================================
  2. //    File:                        CMPDGrayCouncilTabs.cp
  3. // Version:                    1.0 - Sept 9, 1996
  4. //    Author:                    Mike Shields (mshields@inconnect.com)
  5. //                            
  6. //    Copyright ©1996 Mike Shields. All rights reserved.
  7. //    I hereby grant users of CMPDGrayCouncilTabs permission to use it (or any modified 
  8. //    version of it) in applications (or any other type of Macintosh software 
  9. //    like extensions -- freeware, shareware, commercial, or other) for free, 
  10. //    subject to the terms that:
  11. //
  12. //        (1)  This agreement is non-exclusive.
  13. //
  14. //        (2)  I, Mike Shields, retain the copyright to the original source code.
  15. //
  16. //    These two items are the only required conditions for use. However, I do have 
  17. //    an additional request. Note, however, that this is only a request, and 
  18. //    that it is not a required condition for use of this code.
  19. //
  20. //        (1) That I be given credit for CMPDGrayCouncilTabs code in the copyrights or 
  21. //            acknowledgements section of your manual or other appropriate documentation.
  22. //
  23. //
  24. //    I would like to repeat that this last item is only a request. You are prefectly 
  25. //    free to choose not to do any or all of them.
  26. //    
  27. //        This source code is distributed in the hope that it will be useful,
  28. //        but WITHOUT ANY WARRANTY; without even the implied warranty of
  29. //        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  30. // ===========================================================================
  31. //    CMPDGrayCouncilTabs.h        <- double-click + Command-D to see class declaration
  32. //
  33. // A subclass of AGATabPanelPPX which has been adapted to work with the MPD classes.
  34.  
  35. #include "CMPDGrayCouncilTabs.h"
  36.  
  37. //===========================================================================
  38. // CMPDGrayCouncilTabs
  39. //===========================================================================
  40. #pragma mark class CMPDGrayCouncilTabs
  41.  
  42. //----------------------------------------------------------------------------------------
  43. // CMPDGrayCouncilTabs::CreateFromStream
  44. //----------------------------------------------------------------------------------------
  45. CMPDGrayCouncilTabs* CMPDGrayCouncilTabs::CreateFromStream(LStream* inStream)
  46. {
  47.     return new CMPDGrayCouncilTabs(inStream);
  48. }
  49.  
  50. //----------------------------------------------------------------------------------------
  51. // CMPDGrayCouncilTabs::CMPDGrayCouncilTabs
  52. //----------------------------------------------------------------------------------------
  53. CMPDGrayCouncilTabs::CMPDGrayCouncilTabs(LStream* inStream)
  54.     : AGATabPanelPPX(inStream)
  55. {
  56. }
  57.  
  58. //----------------------------------------------------------------------------------------
  59. // CMPDGrayCouncilTabs::~CMPDGrayCouncilTabs
  60. //----------------------------------------------------------------------------------------
  61. CMPDGrayCouncilTabs::~CMPDGrayCouncilTabs()
  62. {
  63. }
  64.     
  65. //----------------------------------------------------------------------------------------
  66. // CMPDGrayCouncilTabs::SetValue
  67. //----------------------------------------------------------------------------------------
  68. void CMPDGrayCouncilTabs::SetValue(SInt32 inValue)
  69. {
  70.     AGATabPanelPPX::SetValue(inValue);
  71.     
  72.     // In addition to setting the current tab we also need to tell our "owner" we've changed.
  73.     ReportPanelIDChanged();
  74. }
  75.  
  76. //----------------------------------------------------------------------------------------
  77. // CMPDGrayCouncilTabs::InsertPanelIDs
  78. //----------------------------------------------------------------------------------------
  79. void CMPDGrayCouncilTabs::InsertPanelIDs(MPDPtr inPanelIDData)
  80. {
  81.     for ( Int16 i = 0; i < inPanelIDData->numItems; i++ )
  82.     {
  83.         // Call the base classes method directly since this class' method is stubbed out
  84.         AGATabPanelPPX::AddPanel(0, inPanelIDData->MPDList[i].name);
  85.     }
  86. }
  87.  
  88. //----------------------------------------------------------------------------------------
  89. // CMPDGrayCouncilTabs::ReportPanelIDChanged
  90. //----------------------------------------------------------------------------------------
  91. void CMPDGrayCouncilTabs::ReportPanelIDChanged(void)
  92. {
  93.     // Wrap the ReportPanelIDChanged with custom color values so that the
  94.     // AGA objects in the panel hierarchy will get the right background
  95.     // colors. This is because we know that the ReportPanelIDChanged method
  96.     // causes a new panel to load. And if it doesn't in the future, then no
  97.     // problem.
  98.     TurnOnCustomAGABackgroundColors(&gAGARamp[r1], &gAGARamp[r2]);
  99.     CMPDPanelSelectControl::ReportPanelIDChanged();
  100.     TurnOffCustomAGABackgroundColors();
  101. }
  102.  
  103. //----------------------------------------------------------------------------------------
  104. // CMPDGrayCouncilTabs::SelectPanelID
  105. //----------------------------------------------------------------------------------------
  106. void CMPDGrayCouncilTabs::SelectPanelID(PanelIDIndexT inPanelID)
  107. {
  108.     // AGATabPanelPPX is 0-based while the MPD classes are 1-based
  109.     SetValue(inPanelID - 1);
  110. }
  111.     
  112. //----------------------------------------------------------------------------------------
  113. // CMPDGrayCouncilTabs::GetCurrentPanelID
  114. //----------------------------------------------------------------------------------------
  115. PanelIDIndexT CMPDGrayCouncilTabs::GetCurrentPanelID(void) const
  116. {
  117.     // AGATabPanelPPX is 0-based while the MPD classes are 1-based
  118.     return (PanelIDIndexT)(AGATabPanelPPX::GetValue() + 1);
  119. }
  120.  
  121. //----------------------------------------------------------------------------------------
  122. // CMPDGrayCouncilTabs::InstallPanel
  123. //----------------------------------------------------------------------------------------
  124. // We overide this to only set the tab labels and make sure the tabs are calculated correctly.
  125. void CMPDGrayCouncilTabs::InstallPanel(SInt32 tabIndex, ResIDT panelResourceID,
  126.                                             StringPtr tabLabel)
  127. {
  128.     if (tabLabel != NULL)
  129.     {
  130.         mAGAObject->SetTabLabel(tabIndex, tabLabel);
  131.         mAGAObject->CalculateTabWidths();
  132.     }
  133. }
  134. //===========================================================================
  135. // CMPDSmallGrayCouncilTabs
  136. //===========================================================================
  137. #pragma mark class CMPDSmallGrayCouncilTabs
  138.  
  139. //----------------------------------------------------------------------------------------
  140. // CMPDSmallGrayCouncilTabs::CreateFromStream
  141. //----------------------------------------------------------------------------------------
  142. CMPDSmallGrayCouncilTabs* CMPDSmallGrayCouncilTabs::CreateFromStream(LStream* inStream)
  143. {
  144.     return new CMPDSmallGrayCouncilTabs(inStream);
  145. }
  146.  
  147. //----------------------------------------------------------------------------------------
  148. // CMPDSmallGrayCouncilTabs::CMPDSmallGrayCouncilTabs
  149. //----------------------------------------------------------------------------------------
  150. CMPDSmallGrayCouncilTabs::CMPDSmallGrayCouncilTabs(LStream* inStream)
  151.     : CMPDGrayCouncilTabs(inStream)
  152. {
  153. }
  154.  
  155. //----------------------------------------------------------------------------------------
  156. // CMPDSmallGrayCouncilTabs::~CMPDSmallGrayCouncilTabs
  157. //----------------------------------------------------------------------------------------
  158. CMPDSmallGrayCouncilTabs::~CMPDSmallGrayCouncilTabs()
  159. {
  160. }
  161.  
  162. //----------------------------------------------------------------------------------------
  163. // CMPDSmallGrayCouncilTabs::CreateAGAObject
  164. //----------------------------------------------------------------------------------------
  165. // basically the same as the AGASmallTabPanelPP method, we just inherit differently
  166. void CMPDSmallGrayCouncilTabs::CreateAGAObject()
  167. {
  168.     CMPDGrayCouncilTabs::CreateAGAObject();
  169.     
  170.     // Set the tabs to use the standard small appearance.
  171.     mAGAObject->SetTabSize(AGATabPanel::kSmallTabs);
  172.     mAGAObject->SetLabelsStyle(gAGAStdBoldSmallStyle);
  173. }
  174.  
  175.